/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.cnam.mobileShopping.entity;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Administrateur
 */
@Entity
@Table(name = "productlist")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Productlist.findAll", query = "SELECT p FROM Productlist p"),
    @NamedQuery(name = "Productlist.findByMlistid", query = "SELECT p FROM Productlist p WHERE p.mlistid = :mlistid"),
    @NamedQuery(name = "Productlist.findByProductlistid", query = "SELECT p FROM Productlist p WHERE p.productlistid = :productlistid"),
    @NamedQuery(name = "Productlist.findByCommonProductlistid", query = "SELECT p FROM Productlist p WHERE p.commonid = :commonproductlistid"),
    @NamedQuery(name = "Productlist.findByStatusid", query = "SELECT p FROM Productlist p WHERE p.statusid = :statusid")})
@XmlAccessorType(XmlAccessType.PUBLIC_MEMBER)
public class Productlist implements Serializable {

   
    private MList mlistid;
    private static final long serialVersionUID = 1L;
   
    private Integer productlistid;
    
  
    private int quantity;
    
  
    private Integer statusid;
    
   
    private User userid;
   
    private Product productid;
    
    
    private Date lastupdatedatetime;

    private String commonid;
    
    private int version;
    
    @Column(name = "version")
    @XmlElement(name="version")
    public int getVersion() {
        return version;
    }

    public void setVersion(int version) {
        this.version = version;
    }

    @Column(name = "commonid")
     @XmlElement(name="commonid")
    public String getCommonid() {
        return commonid;
    }

    public void setCommonid(String commonid) {
        this.commonid = commonid;
    }
    
    public Productlist() {
    }

    public Productlist(Integer productlistid) {
        this.productlistid = productlistid;
    }

    public Productlist(Integer productlistid, int quantity) {
        this.productlistid = productlistid;
        this.quantity = quantity;
    }
    
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "productlistid")
    @XmlElement(name="productlistid")
    public Integer getProductlistid() {
        return productlistid;
    }

    public void setProductlistid(Integer productlistid) {
        this.productlistid = productlistid;
    }
    
    @Basic(optional = false)
    @Column(name = "quantity")
    @XmlElement(name="quantity")
    public int getQuantity() {
        return quantity;
    }

    public void setQuantity(int quantity) {
        this.quantity = quantity;
    }
    
    @Column(name = "statusid")
    @XmlElement(name="statusid")
    public Integer getStatusid() {
        return statusid;
    }

    public void setStatusid(Integer statusid) {
        this.statusid = statusid;
    }

    @JoinColumn(name = "userid", referencedColumnName = "userid")
    @ManyToOne
    @XmlTransient
    public User getUserid() {
        return userid;
    }

    public void setUserid(User userid) {
        this.userid = userid;
    }
 
    @JoinColumn(name = "productid", referencedColumnName = "productid")
    @ManyToOne
    @XmlTransient
    public Product getProductid() {
        return productid;
    }

    public void setProductid(Product productid) {
        this.productid = productid;
    }

  
    
    @JoinColumn(name = "mlistid", referencedColumnName = "mlistid")
    @ManyToOne
    @XmlTransient
    public MList getMlistid() {
        return mlistid;
    }

    public void setMlistid(MList mlistid) {
        this.mlistid = mlistid;
    }
    
    @XmlElement(name="mlistId")
    public Integer getMlistIdentifiant(){
        return mlistid.getMlistid();
    }
    
    @Column(name = "lastupdatedatetime")
    @Temporal(javax.persistence.TemporalType.DATE)
    @XmlElement(name="lastupdatedatetime")
    public Date getLastupdatedatetime() {
        return lastupdatedatetime;
    }

    public void setLastupdatedatetime(Date lastupdatedatetime) {
        this.lastupdatedatetime = lastupdatedatetime;
    }
    
    @XmlElement(name="productid")
    public Integer getProductIdentifiant() {
        return productid.getProductid();
    }
    
    @XmlElement(name="userid")
            public Integer getUserIdentifiant(){
        return userid.getUserid();
    }
    
    
    @Override
    public int hashCode() {
        int hash = 0;
        hash += (productlistid != null ? productlistid.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Productlist)) {
            return false;
        }
        Productlist other = (Productlist) object;
        if ((this.productlistid == null && other.productlistid != null) || (this.productlistid != null && !this.productlistid.equals(other.productlistid))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "org.cnam.mobileShopping.entity.Productlist[ productlistid=" + productlistid + " ]";
    }
}
